#include "AutoLock.h"

DEF_BEG_LIBTOOLS

CAutoLock::CAutoLock(CMutexBase *pBase) :_bLock(false)
{
	 _mutex = pBase;
	Lock();
}

CAutoLock::~CAutoLock()
{
	Unlock();
}

void CAutoLock::Lock()
{
	if (!_bLock)
	{
		 _mutex->Lock();
		 _bLock = true;
	}
}

void CAutoLock::Unlock()
{
	if (_bLock)
	{
		 _mutex->Unlock();
		 _bLock = false;
	}
}

DEF_END_LIBTOOLS